<template>
  <page-form :x-uri="uri" :bind-rules="rules">
    <!-- 自定义tab -->
    <template v-slot:page-tabs>
      <tabs />
    </template>
  </page-form>
</template>

<script>
import PageForm from '@public/template/page_form.vue';
import Tabs from './components/tabs.vue';
export default {
  components: {
    PageForm,
    Tabs
  },
  data() {
    const validator = [
      { required: true, message: '请填写获得的积分', trigger: ['blur', 'change'] },
      {
        validator: (rule, value, callback) => {
          const reg = /^(0|\+?[1-9][0-9]*)$/;
          if (!reg.test(value)) {
            return callback(new Error('获得的积分只能为正整数和0'));
          }
          callback();
        },
        trigger: ['blur', 'change']
      }
    ];
    return {
      uri: '/admin/finance/credit/config',
      rules: {
        register: validator,
        invite_register: validator,
        sign_in: validator
      }
    };
  }
};
</script>
